package com.mozz.finally_work.servlet.api;

import com.mozz.finally_work.utils.ParseMarkdown;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;


// 用于解析markdown的异步请求
@WebServlet(name = "DecodeMarkdownServlet", value = "/DecodeMarkdownServlet")
public class DecodeMarkdownServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String resource = request.getParameter("resource");
        // 解析markdown
        String result = ParseMarkdown.parse(resource);
        response.setHeader("Content-Type", "application/json; charset=UTF-8");
        response.getWriter().write(result);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
